<template>
  <div class="home-header">
    <van-tabs @click="tabClick($event)">
      
      <van-tab 
      v-for="item in cates"  
      :key="item.id" 
      :title="item.catename" 
      :name="item.id">
      </van-tab>

    </van-tabs>
  </div>
</template>

<script>
import { getHomeCate } from "../../../http/http";
export default {
  data() {
    return {
      //初始化数据
      cates: [],
    };
  },
  mounted() {
    getHomeCate().then((res) => {
      // console.log(res);
      this.cates = res.data.list;
    });
  },
  methods:{
      tabClick(e){
            // console.log(e);
         this.$router.push('/list?id=' + e)
      }
  }
};
</script>

<style>
.home-header {
  background: pink;
  overflow: hidden;
}
.home-header a {
  float: left;
  margin: 0.2rem;
  line-height: 0.6rem;
}
</style>